<template>
  <view class="index">
    <view class="jtop">
      <view class="status_bar"><!-- 这里是状态栏 --></view>
      <view class="jtop_l" @tap="navigateBack"
        ><image src="../../static/img/ic_back.png"></image
      ></view>
      <view class="jtop_c">管理团队</view>
      <!-- <view class="jtop_r" @tap="jshow_pop"><image src="../../static/img/index/ic_ellipsis.png"></image></view> -->
      <!-- <view class="jtop_r" @tap="add"><image src="../../static/img/index/ic_add.png"></image></view> -->
    </view>
    <view class="tophr"></view>

    <view class="addb">
      <view class="addbi" @tap="define">
        <text class="addbil ell">{{ jenterprise }}</text>
        <image src="../../static/img/jt.png"></image>
      </view>
    </view>

    <view class="dus_t">团队成员</view>

    <view class="ptt">
      <view class="ptft" @tap="add">
        <image src="../../static/img/index/ic_add_1.png"></image>
        <text>添加成员...</text>
      </view>
    </view>

    <view class="dus_boxs">
      <view class="dus_box" v-for="(item, index) in items" :key="item.id">
        <image
          src="../../static/img/index/new/ic_phone_blue.png"
          class="dus_box_s"
          @click="pc(item.userInfoResponse.phone)"
        ></image>

        <view class="dus_box_tx">
          <image
            :src="item.userInfoResponse.avatar"
            class=""
            @tap="
              tel_more(
                item.id,
                item.name,
                item.duty,
                item.phone,
                item.userInfoResponse.gender,
                item.userInfoResponse.email,
                item.userInfoResponse.avatar,
              )
            "
            v-if="item.register"
          ></image>

          <image
            :src="mrtx"
            v-show="!item.register"
            @tap="
              tel_more(
                item.id,
                item.name,
                item.duty,
                item.phone,
                '-',
                '-',
                mrtx,
              )
            "
          ></image>
          <text class="" v-show="!item.register">未注册</text>
        </view>

        <view
          class="dus_box_l"
          @tap="
            tel_more(
              item.id,
              item.name ? item.name : item.userInfoResponse.realName,
              item.duty,
              item.phone ? item.phone : item.userInfoResponse.phone,
              item.userInfoResponse ? item.userInfoResponse.gender : '-',
              item.userInfoResponse ? item.userInfoResponse.email : '-',
              item.userInfoResponse ? item.userInfoResponse.avatar : mrtx,
            )
          "
        >
          <text class="dus_box_lt">{{
            item.name ? item.name : item.userInfoResponse.realName
          }}</text>
          <text class="dus_box_lf">{{ item.duty }}</text>
        </view>
      </view>

      <!-- <view class="dus_box" @tap="tel_more">
				<image src="../../static/img/index/new/ic_phone_blue.png"  class="dus_box_s"></image>
				<image src="../../static/img/jhead_portrait.png" class="dus_box_tx" ></image>
				<view class="dus_box_l">
					<text class="dus_box_lt">小布衣</text>
					<text class="dus_box_lf">底层搬砖工</text>
				</view>
			</view>
			
			
			<view class="dus_box" @tap="tel_more">
				
				<image src="../../static/img/index/new/ic_phone_blue.png"  class="dus_box_s"></image>
				
				<view class="dus_box_tx">
					<image src="../../static/img/jhead_portrait.png" class="" ></image>
					<text class="">未注册</text>
				</view>
				
				
				<view class="dus_box_l">
					<text class="dus_box_lt">小布衣</text>
					<text class="dus_box_lf">底层搬砖工</text>
				</view>
				
			</view> -->
    </view>

    <!-- 弹出层 -->
    <view :class="[ashowpop ? 'tc' : 'tc hide']">
      <view class="jtop_bj" @click="jshow_pop"></view>

      <view class="tc_fbox">
        <view class="tc_fbox_bt2" @click="jshow_pop">
          解散企业/团队
        </view>
        <view class="tc_fbox_bt" @click="jshow_pop">
          取消
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import request from '@/common/request.js';
import { mapState } from 'vuex';

export default {
  computed: mapState(['forcedLogin', 'hasLogin', 'userName']),
  data() {
    return {
      repeat_click: true,
      ashowpop: false,
      corpId: '',
      jenterprise: uni.getStorageSync('user').corp_name,
      items: [],
      mrtx: '../../static/img/Default_avatar.png',
    };
  },

  onShow() {
    var id = uni.getStorageSync('user').corpBaseInfoResponse.id;
    // 获取用户信息
    request({
      url: '/ucenter/corp-user/corp/' + id,
      method: 'GET',

      success: res => {
        console.log('企业', res.data.data);

        // 已经授权了、查询到用户的数据了
        if (res.data.success == true) {
          this.corpId = res.data.data.corpBaseInfoResponse.id;
          this.jenterprise = res.data.data.corpBaseInfoResponse.fullName;
          uni.setStorageSync('jenterprise', res.data.data.corpBaseInfoResponse);
        } else {
          // 错误
          this.repeat_click = true;
          uni.showToast({
            title: res.data.msg,
            icon: 'none',
          });
        }
      },
    });

    request({
      url: `/ucenter/corp-user/list`,

      data: {
        corpId: uni.getStorageSync('user').corpBaseInfoResponse.id,
      },

      method: 'GET',
      success: openIdRes => {
        console.log('users:', openIdRes);

        this.items = openIdRes.data.data;
      },
      fail: () => {
        this.repeat_click = true;
        uni.showToast({
          title: '服务器开小差，请稍后~',
          icon: 'none',
        });
        return false;
      },
    });
  },

  methods: {
    pc(e) {
      uni.makePhoneCall({
        phoneNumber: e,
      });
    },
    define() {
      uni.navigateTo({
        url: '../user/tream_name',
      });
    },
    jshow_pop() {
      this.ashowpop = !this.ashowpop;
    },
    navigateBack() {
      uni.switchTab({
        url: '/pages/user/user',
      });

      // uni.navigateBack()
    },
    tel_more(a, b, c, d, e, f, g) {
      uni.setStorageSync('jenterpriselstx', g);
      uni.navigateTo({
        url:
          '../user/tream_more?id=' +
          a +
          '&realname=' +
          b +
          '&duty=' +
          c +
          '&mobile=' +
          d +
          '&sex=' +
          e +
          '&mail=' +
          f +
          '&jhead_portrait=' +
          g,
      });
    },
    add() {
      uni.navigateTo({
        url: '../user/tream_add?id=' + this.corpId,
      });
    },
  },
};
</script>

<style>
.tc {
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10000;
  display: block;
}
.jtop_bj {
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10000;
}
.tc_fbox_bt {
  width: 100%;
  height: 90rpx;
  line-height: 90rpx;
  display: block;
  float: left;
  text-align: center;
  font-size: 36rpx;
  color: #000000;
  border-top: 20rpx solid #f2f2f2;
  background: #ffffff;
}
.tc_fbox {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  background: #f2f2f2;
  position: fixed;
  left: 0;
  bottom: 0;
  z-index: 10001;
}
.tc_fbox_bt2 {
  width: 100%;
  height: 90rpx;
  line-height: 90rpx;
  display: block;
  float: left;
  text-align: center;
  font-size: 36rpx;
  color: #eb5342;
  border-top: 0rpx solid #f2f2f2;
  background: #ffffff;
}

.addb {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  background: #ffffff;
  border: 1px solid #dddddd;
  border-left: 0;
  border-right: 0;
  margin: 0rpx 0 0;
}
.addbi {
  width: 720rpx;
  margin: 0 0 0 30rpx;
  height: 90rpx;
  display: block;
  float: left;
  background: #ffffff;
  border-bottom: 1px solid #dddddd;
}
.addb .addbi:last-child {
  border: none;
}
.addbi .addbil {
  width: 500rpx;
  height: 90rpx;
  display: block;
  float: left;
  line-height: 90rpx;
  font-size: 34rpx;
  color: #000000;
}
.addbi .addbir {
  width: auto;
  height: 90rpx;
  display: block;
  float: left;
  line-height: 90rpx;
  font-size: 32rpx;
  color: #000000;
}
.addbi image {
  width: 16rpx;
  height: 25rpx;
  display: block;
  float: right;
  margin: 33rpx 30rpx 0 30rpx;
}
.addi textarea {
  width: 690rpx;
  height: 150rpx;
  display: block;
  float: left;
  margin: 0rpx 30rpx 20rpx;
  text-align: left;
  line-height: 40rpx;
  font-size: 34rpx;
  color: #000000;
}

.ptt {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  background: #ffffff;
  border: 1px solid #dddddd;
  border-left: 0;
  border-right: 0;
  margin: 0rpx 0 0;
}
.pttl {
  width: 84rpx;
  height: 84rpx;
  display: block;
  float: left;
  margin: 18rpx 20rpx 18rpx 30rpx;
}
.pttr {
  width: 400rpx;
  height: 84rpx;
  display: block;
  float: left;
  margin: 18rpx 0rpx 0rpx 0rpx;
}
.pttrt {
  width: 100%;
  height: 42rpx;
  line-height: 42rpx;
  display: block;
  float: left;
  font-size: 34rpx;
  color: #000000;
}
.pttrf {
  width: 100%;
  height: 42rpx;
  line-height: 42rpx;
  display: block;
  float: left;
  font-size: 24rpx;
  color: #999999;
}
.pttjt {
  width: 16rpx;
  height: 25rpx;
  display: block;
  float: right;
  margin: 48rpx 30rpx 0 30rpx;
}
.ptf {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  background: #ffffff;
  border: 1px solid #dddddd;
  border-left: 0;
  border-right: 0;
  margin: 20rpx 0 0;
}
.ptft {
  width: 720rpx;
  margin: 0 0 0 30rpx;
  height: 90rpx;
  display: block;
  float: left;
  background: #ffffff;
}
.ptft image {
  width: 48rpx;
  height: 48rpx;
  display: block;
  float: left;
  margin: 21rpx 20rpx 0 0rpx;
}
.ptft text {
  width: auto;
  height: 48rpx;
  display: block;
  float: left;
  margin: 21rpx 20rpx 0 0rpx;
  font-size: 34rpx;
  line-height: 48rpx;
  color: #000000;
}

.tophr {
  width: 100%;
  height: 88rpx;
}
.uni-searchbar {
  box-shadow: none;
}
.tc {
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10000;
  display: block;
}
.dus {
  width: 100%;
  height: 90rpx;
  display: block;
  float: left;
  border: 1px solid #dddddd;
  border-left: 0;
  border-right: 0;
  background: #ffffff;
}
.dusl {
  width: 48rpx;
  height: 48rpx;
  display: block;
  float: left;
  margin: 21rpx 22rpx 21rpx 30rpx;
}
.dusc {
  width: auto;
  height: 42rpx;
  font-size: 34rpx;
  line-height: 42rpx;
  color: #000000;
  display: block;
  float: left;
  margin: 24rpx 0;
}
.dusr {
  width: 16rpx;
  height: 25rpx;
  display: block;
  float: right;
  margin: 33rpx 30rpx 0 0;
}
.dus_t {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  font-size: 24rpx;
  line-height: 32rpx;
  color: #999999;
  padding: 30rpx 30rpx 30rpx;
  box-sizing: border-box;
  background: rgb(242, 242, 242);
}
.dus_tl {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  font-size: 24rpx;
  line-height: 32rpx;
  color: #999999;
  padding: 4rpx 30rpx;
  box-sizing: border-box;
}
.dus_boxs {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  border: 1px solid #dddddd;
  border-left: 0;
  border-right: 0;
  background: #ffffff;
  border-top: 0;
}
.dus_box {
  width: 720rpx;
  margin: 0 0 0 30rpx;
  height: 120rpx;
  display: block;
  float: left;
  background: #ffffff;
  border-bottom: 1px solid #dddddd;
}
.dus_boxs .dus_box:last-child {
  border: 0;
}
.dus_box_s {
  width: 48rpx;
  height: 48rpx;
  display: block;
  float: right;
  margin: 36rpx 30rpx 0 0;
}
.dus_box_tx {
  width: 84rpx;
  height: 84rpx;
  display: block;
  float: left;
  margin: 18rpx 20rpx 0rpx 0;
  position: relative;
}

.dus_box_tx image {
  width: 84rpx;
  height: 84rpx;
  display: block;
  float: left;
  position: absolute;
  top: 0;
  left: 0;
}
.dus_box_tx text {
  width: 84rpx;
  height: 30rpx;
  display: block;
  float: left;
  position: absolute;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  text-align: center;
  line-height: 30rpx;
  font-size: 20rpx;
  color: #ffffff;
  left: 0;
}

.dus_box_l {
  width: 500rpx;
  height: auto;
  display: block;
  float: left;
  margin: 0rpx 0 0rpx 0;
}
.dus_box_lt {
  width: 100%;
  height: 42rpx;
  display: block;
  float: left;
  margin: 18rpx 0 10rpx 0;
  font-size: 34rpx;
  line-height: 42rpx;
  color: #000000;
}
.dus_box_lf {
  width: 100%;
  height: 32rpx;
  display: block;
  float: left;
  margin: 0rpx 0 0rpx 0;
  font-size: 24rpx;
  line-height: 32rpx;
  color: #999999;
}
/* .dus_box_sx{ opacity: .5;} */

.dcf {
  width: 100%;
  height: 120rpx;
  display: block;
  float: left;
  position: fixed;
  left: 0;
  bottom: 0;
  background: #ffffff;
  box-shadow: inset 0px 1px 0px #dddddd;
  z-index: 1000;
  padding: 18rpx 30rpx;
  box-sizing: border-box;
}
.dcf_tx {
  width: 84rpx;
  height: 84rpx;
  display: block;
  float: left;
  margin: 0rpx 20rpx 0rpx 0;
}
.dcf_t {
  width: auto;
  height: 84rpx;
  line-height: 84rpx;
  display: block;
  float: right;
  margin: 0rpx 0rpx 0rpx 0;
  font-size: 36rpx;
  color: #256aff;
}

.index {
  background: #ffffff;
  width: 100%;
  height: auto;
}
.jtop {
  width: 100%;
  height: 88rpx;
  background: #ffffff;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
}
.jtop_l {
  width: auto;
  height: 88rpx;
  display: block;
  float: left;
  font-size: 32rpx;
  color: #000000;
  line-height: 88rpx;
  margin: 0 0 0 30rpx;
}
.jtop_l image {
  width: 48rpx;
  height: 48rpx;
  display: block;
  float: left;
  margin: 20rpx 0 20rpx 0;
}
.jtop_r {
  width: auto;
  height: 88rpx;
  display: block;
  float: right;
  margin: 20rpx 20rpx 0 0;
  line-height: 88rpx;
  font-size: 32rpx;
  color: #000000;
  color: #256aff;
}
.jtop_r image {
  width: 48rpx;
  height: 48rpx;
  display: block;
  float: left;
}
.jtop_c {
  width: 70%;
  height: 48rpx;
  line-height: 48rpx;
  display: block;
  float: left;
  position: fixed;
  top: 20rpx;
  left: 15%;
  text-align: center;
  font-size: 36rpx;
  color: #000000;
}
.jtop_c image {
  width: 36rpx;
  height: 36rpx;
  display: inline-block;
  float: none;
  margin-bottom: -5rpx;
  margin-left: 5rpx;
}
.jtop_b {
  width: 100%;
  height: auto;
  background: #ffffff;
  position: fixed;
  top: 88rpx;
  left: 0;
  z-index: 1001;
}

.uni-searchbar {
  background: rgb(242, 242, 242);
}
.index .uni-searchbar__box {
  background: #ffffff !important;
}
</style>
